﻿@page "/datagrid/row-height"

@using Syncfusion.Blazor.Grids
@using Syncfusion.Blazor.Navigations
@using blazor_griddata

@inherits SampleBaseComponent;

<SampleDescription>
    <p>This sample demonstrates the row height feature of the DataGrid. In this demo, the <b>RowHeight</b> for all the DataGrid rows can be changed as <b>20px</b>, <b>40px</b> and <b>60px</b> on ToolBar button click.</p>
</SampleDescription>
<ActionDescription>
   <p>The row height for the DataGrid rows can be set using the <code><a target='_blank' class='code' href='https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_RowHeight'>RowHeight</a></code> property.</p>
   <p>More information on the row height feature can be found in this <a target='_blank' href='https://blazor.syncfusion.com/documentation/grid/row/#row-height'>documentation section</a>.</p>
</ActionDescription>

@{
    List<ItemModel> Toolbar = new List<ItemModel>();
    Toolbar.Add(new ItemModel { PrefixIcon = "e-small-icon", Id = "big", Align = ItemAlign.Right, TooltipText="60px"  });
    Toolbar.Add(new ItemModel { PrefixIcon = "e-medium-icon", Id = "medium", Align = ItemAlign.Right, TooltipText="40px" });
    Toolbar.Add(new ItemModel { PrefixIcon = "e-big-icon", Id = "small", Align = ItemAlign.Right, TooltipText="20px" });
}

<div class="col-lg-12 control-section">
    <div class="content-wrapper">
        <div class="row">

            <SfGrid @ref="Grid" DataSource="@GridData" Height="400" RowHeight="@GridRowHeight" Toolbar="Toolbar">
                <GridEvents OnToolbarClick="ToolbarClick" TValue="OrdersDetails"></GridEvents>
                <GridColumns>
                    <GridColumn Field=@nameof(OrdersDetails.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="150"></GridColumn>
                    <GridColumn Field=@nameof(OrdersDetails.CustomerID) HeaderText="Customer Name" Width="130"></GridColumn>
                    <GridColumn Field=@nameof(OrdersDetails.OrderDate) HeaderText="Order Date" Format="d" TextAlign="TextAlign.Right" Width="130"></GridColumn>
                    <GridColumn Field=@nameof(OrdersDetails.Freight) HeaderText="Freight" TextAlign="TextAlign.Right" Width="130" Format="C2"></GridColumn>
                    <GridColumn Field=@nameof(OrdersDetails.ShippedDate) HeaderText="Shipped Date" Width="150" TextAlign="TextAlign.Right" Format="d"></GridColumn>
                    <GridColumn Field=@nameof(OrdersDetails.ShipCountry) HeaderText="Ship Country" Width="150"></GridColumn>
                </GridColumns>
            </SfGrid>

        </div>
    </div>
</div>

<style>

    @@font-face {
        font-family: 'e-grid-rowheight';
        src: url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAAKAIAAAwAgT1MvMj1uSfkAAAEoAAAAVmNtYXDOLM5rAAABkAAAAEJnbHlm/CWF1QAAAeAAAAGIaGVhZBRfqPEAAADQAAAANmhoZWEIUQQFAAAArAAAACRobXR4EAAAAAAAAYAAAAAQbG9jYQDyALYAAAHUAAAACm1heHABFAB4AAABCAAAACBuYW1l2jjwtgAAA2gAAAKRcG9zdJYOJ5oAAAX8AAAARgABAAAEAAAAAFwEAAAAAAAD9AABAAAAAAAAAAAAAAAAAAAABAABAAAAAQAAWBvKcl8PPPUACwQAAAAAANimsgAAAAAA2KayAAAAAAAD9AP0AAAACAACAAAAAAAAAAEAAAAEAGwABgAAAAAAAgAAAAoACgAAAP8AAAAAAAAAAQQAAZAABQAAAokCzAAAAI8CiQLMAAAB6wAyAQgAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABA5wHnBwQAAAAAXAQAAAAAAAABAAAAAAAABAAAAAQAAAAEAAAABAAAAAAAAAIAAAADAAAAFAADAAEAAAAUAAQALgAAAAYABAABAALnAucH//8AAOcB5wf//wAAAAAAAQAGAAgAAAACAAEAAwAAAAAAAAAuALYAxAAAAAYAAAAAA8UD9AADAAcACwAPABMAFwAANyE1ISchNSE1ITUhNyE1ITchNSEnITUhPQOH/HkCA4f8eQOH/HkCA4f8eQEDh/x5AQOH/HkMX1dfVl9WXlVfV18AAAAAAwAAAAAD9ANtACMARwBrAAA3FR8HIT8HNS8HIQ8GAxUfByE/BzUvByEPBgMVHwchPwc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GQAIAB1AHMAaQBuAGcAIABTAHkAbgBjAGYAdQBzAGkAbwBuACAATQBlAHQAcgBvACAAUwB0AHUAZABpAG8AdwB3AHcALgBzAHkAbgBjAGYAdQBzAGkAbwBuAC4AYwBvAG0AAAAAAgAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAQIBAwEEAQUADWFsaWduLWp1c3RpZnkEbWVudQVtaW51cwAAAAA=) format('truetype');
        font-weight: normal;
        font-style: normal;
    }

    .e-grid .e-small-icon::before {
        font-family: 'e-grid-rowheight';
        content: '\e707';
    }

    .e-grid .e-medium-icon::before {
        font-family: 'e-grid-rowheight';
        content: '\e701';
    }

    .e-grid .e-big-icon::before {
        font-family: 'e-grid-rowheight';
        content: '\e702';
    }
</style>

@code{
    SfGrid<OrdersDetails> Grid;

    public List<OrdersDetails> GridData { get; set; }
	
	public int GridRowHeight = 20;

    protected override void OnInitialized()
    {
        GridData = OrdersDetails.GetAllRecords();
    }

    public void ToolbarClick(Syncfusion.Blazor.Navigations.ClickEventArgs args)
    {
        if (args.Item.Id == "small") {
            GridRowHeight = 20;
        }
        if (args.Item.Id == "medium") {
            GridRowHeight = 40;
        }
        if (args.Item.Id == "big") {
            GridRowHeight= 60;
        }
    }
}
